/*
 * Allwinner SoCs display driver.
 *
 * Copyright (C) 2016 Allwinner.
 *
 * This file is licensed under the terms of the GNU General Public
 * License version 2.  This program is licensed "as is" without any
 * warranty of any kind, whether express or implied.
 */

/*
 *Model name : LX50HDI4002-V0
 *Resolution rate: 720*1280
 *Size : 5 inch
 *Interface: MIPI DSI
*/

#include "eagle_1_720_1280.h"

static void LCD_power_on(u32 sel);
static void LCD_power_off(u32 sel);
static void LCD_bl_open(u32 sel);
static void LCD_bl_close(u32 sel);

static void LCD_panel_init(u32 sel);
static void LCD_panel_exit(u32 sel);

static void LCD_cfg_panel_info(panel_extend_para *info)
{
	u32 i = 0, j = 0;
	u32 items;
	u8 lcd_gamma_tbl[][2] = {
		/* {input value, corrected value} */
		{0, 0},
		{15, 15},
		{30, 30},
		{45, 45},
		{60, 60},
		{75, 75},
		{90, 90},
		{105, 105},
		{120, 120},
		{135, 135},
		{150, 150},
		{165, 165},
		{180, 180},
		{195, 195},
		{210, 210},
		{225, 225},
		{240, 240},
		{255, 255},
	};

	u32 lcd_cmap_tbl[2][3][4] = {
		{
		 {LCD_CMAP_G0, LCD_CMAP_B1, LCD_CMAP_G2, LCD_CMAP_B3},
		 {LCD_CMAP_B0, LCD_CMAP_R1, LCD_CMAP_B2, LCD_CMAP_R3},
		 {LCD_CMAP_R0, LCD_CMAP_G1, LCD_CMAP_R2, LCD_CMAP_G3},
		 },
		{
		 {LCD_CMAP_B3, LCD_CMAP_G2, LCD_CMAP_B1, LCD_CMAP_G0},
		 {LCD_CMAP_R3, LCD_CMAP_B2, LCD_CMAP_R1, LCD_CMAP_B0},
		 {LCD_CMAP_G3, LCD_CMAP_R2, LCD_CMAP_G1, LCD_CMAP_R0},
		 },
	};

	items = sizeof(lcd_gamma_tbl) / 2;
	for (i = 0; i < items - 1; i++) {
		u32 num = lcd_gamma_tbl[i + 1][0] - lcd_gamma_tbl[i][0];

		for (j = 0; j < num; j++) {
			u32 value = 0;

			value =
			    lcd_gamma_tbl[i][1] +
			    ((lcd_gamma_tbl[i + 1][1] -
			      lcd_gamma_tbl[i][1]) * j) / num;
			info->lcd_gamma_tbl[lcd_gamma_tbl[i][0] + j] =
			    (value << 16) + (value << 8) + value;
		}
	}
	info->lcd_gamma_tbl[255] =
	    (lcd_gamma_tbl[items - 1][1] << 16) +
	    (lcd_gamma_tbl[items - 1][1] << 8) + lcd_gamma_tbl[items - 1][1];

	memcpy(info->lcd_cmap_tbl, lcd_cmap_tbl, sizeof(lcd_cmap_tbl));

}

static s32 LCD_open_flow(u32 sel)
{
	/* open lcd power, and delay 50ms */
	LCD_OPEN_FUNC(sel, LCD_power_on, 30);
	/* open lcd power, than delay 200ms */
	LCD_OPEN_FUNC(sel, LCD_panel_init, 50);
	/* open lcd controller, and delay 100ms */
	LCD_OPEN_FUNC(sel, sunxi_lcd_tcon_enable, 100);
	/* open lcd backlight, and delay 0ms */
	LCD_OPEN_FUNC(sel, LCD_bl_open, 0);

	return 0;
}

static s32 LCD_close_flow(u32 sel)
{
	/* close lcd backlight, and delay 0ms */
	LCD_CLOSE_FUNC(sel, LCD_bl_close, 0);
	/* close lcd controller, and delay 0ms */
	LCD_CLOSE_FUNC(sel, sunxi_lcd_tcon_disable, 0);
	/* open lcd power, than delay 200ms */
	LCD_CLOSE_FUNC(sel, LCD_panel_exit, 200);
	/* close lcd power, and delay 500ms */
	LCD_CLOSE_FUNC(sel, LCD_power_off, 500);

	return 0;
}

static void LCD_power_on(u32 sel)
{
	/* config lcd_powerX pin to open lcd power */
	/*vcc18-dsi*/
	sunxi_lcd_power_enable(sel, 0);
	sunxi_lcd_delay_ms(10);
	/*vcc-3v3*/
	sunxi_lcd_power_enable(sel, 1);
	sunxi_lcd_delay_ms(10);
	/*vcc-lcd*/
	sunxi_lcd_power_enable(sel, 2);
	sunxi_lcd_delay_ms(10);
	/*initialize the pins which needed*/
	sunxi_lcd_pin_cfg(sel, 1);
}

static void LCD_power_off(u32 sel)
{
	sunxi_lcd_pin_cfg(sel, 0);
	sunxi_lcd_delay_ms(10);
	sunxi_lcd_power_disable(sel, 2);
	sunxi_lcd_delay_ms(10);
	sunxi_lcd_power_disable(sel, 1);
	sunxi_lcd_delay_ms(10);
	sunxi_lcd_power_disable(sel, 0);

}

static void LCD_bl_open(u32 sel)
{
	sunxi_lcd_pwm_enable(sel);
	sunxi_lcd_backlight_enable(sel);
}

static void LCD_bl_close(u32 sel)
{
	/* config lcd_bl_en pin to close lcd backlight */
	sunxi_lcd_backlight_disable(sel);
	sunxi_lcd_pwm_disable(sel);
}

static void LCD_panel_init(u32 sel)
{
	sunxi_lcd_dsi_clk_enable(sel);
	sunxi_lcd_delay_ms(10);

	sunxi_lcd_dsi_dcs_write_1para(sel, 0xFE, 0x01);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x24, 0xC0);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x25, 0x53);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x26, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x27, 0x0A);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x29, 0x0A);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x2B, 0xE5);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x16, 0x52);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x2F, 0x54);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x34, 0x57);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x1B, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x12, 0x0A);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x1A, 0x06);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x46, 0x3A);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x52, 0x78);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x53, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x54, 0x78);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x55, 0x00);
	sunxi_lcd_delay_ms(200);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xFE, 0x03);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x00, 0x05);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x01, 0x16);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x02, 0x09);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x03, 0x0D);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x04, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x05, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x06, 0x50);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x07, 0x05);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x08, 0x16);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x09, 0x0B);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x0A, 0x0F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x0B, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x0C, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x0D, 0x50);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x0E, 0x04);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x0F, 0x05);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x10, 0x06);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x11, 0x07);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x12, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x13, 0xA9);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x14, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x15, 0xC4);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x16, 0x08);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x17, 0x08);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x18, 0x09);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x19, 0x0A);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x1A, 0x0B);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x1B, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x1C, 0xA9);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x1D, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x1E, 0x84);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x1F, 0x08);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x20, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x21, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x22, 0x04);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x23, 0x1B);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x24, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x25, 0x28);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x26, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x27, 0x1F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x28, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x29, 0x28);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x2A, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x2B, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x2D, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x2F, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x30, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x31, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x32, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x33, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x34, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x35, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x36, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x37, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x38, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x39, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x3A, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x3B, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x3D, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x3F, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x40, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x3F, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x41, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x42, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x43, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x44, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x45, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x46, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x47, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x48, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x49, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x4A, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x4B, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x4C, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x4D, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x4E, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x4F, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x50, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x51, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x52, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x53, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x54, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x55, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x56, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x58, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x59, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x5A, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x5B, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x5C, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x5D, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x5E, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x5F, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x60, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x61, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x62, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x63, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x64, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x65, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x66, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x67, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x68, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x69, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x6A, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x6B, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x6C, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x6D, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x6E, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x6F, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x70, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x71, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x72, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x73, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x74, 0x04);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x75, 0x04);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x76, 0x04);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x77, 0x04);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x78, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x79, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x7A, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x7B, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x7C, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x7D, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x7E, 0x86);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x7F, 0x02);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x80, 0x0E);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x81, 0x0C);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x82, 0x0A);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x83, 0x08);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x84, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x85, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x86, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x87, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x88, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x89, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x8A, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x8B, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x8C, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x8D, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x8E, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x8F, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x90, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x91, 0x04);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x92, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x93, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x94, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x95, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x96, 0x05);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x97, 0x01);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x98, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x99, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x9A, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x9B, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x9C, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x9D, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x9E, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x9F, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xA0, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xA2, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xA3, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xA4, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xA5, 0x09);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xA6, 0x0B);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xA7, 0x0D);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xA9, 0x0F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xAA, 0x03);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xAB, 0x07);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xAC, 0x01);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xAD, 0x05);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xAE, 0x0D);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xAF, 0x0F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xB0, 0x09);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xB1, 0x0B);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xB2, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xB3, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xB4, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xB5, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xB6, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xB7, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xB8, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xB9, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xBA, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xBB, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xBC, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xBD, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xBE, 0x07);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xBF, 0x03);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xC0, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xC1, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xC2, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xC3, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xC4, 0x02);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xC5, 0x06);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xC6, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xC7, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xC8, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xC9, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xCA, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xCB, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xCC, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xCD, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xCE, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xCF, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xD0, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xD1, 0x3F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xD2, 0x0A);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xD3, 0x08);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xD4, 0x0E);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xD5, 0x0C);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xD6, 0x04);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xD7, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xDC, 0x02);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xDE, 0x10);
	sunxi_lcd_delay_ms(200);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xFE, 0x04);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x60, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x61, 0x0B);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x62, 0x12);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x63, 0x0E);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x64, 0x07);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x65, 0x15);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x66, 0x0F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x67, 0x0B);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x68, 0x16);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x69, 0x0C);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x6A, 0x11);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x6B, 0x09);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x6C, 0x11);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x6D, 0x19);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x6E, 0x13);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x6F, 0x0A);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x70, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x71, 0x0B);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x72, 0x12);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x73, 0x0E);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x74, 0x07);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x75, 0x15);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x76, 0x0F);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x77, 0x0B);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x78, 0x16);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x79, 0x0C);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x7A, 0x11);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x7B, 0x09);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x7C, 0x11);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x7D, 0x19);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x7E, 0x13);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x7F, 0x0A);
	sunxi_lcd_delay_ms(200);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xFE, 0x0E);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x01, 0x75);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x49, 0x56);
	sunxi_lcd_delay_ms(200);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0xFE, 0x00);
	sunxi_lcd_dsi_dcs_write_1para(sel, 0x58, 0x00);//0xA9
	sunxi_lcd_dsi_dcs_write_0para(sel, DSI_DCS_EXIT_SLEEP_MODE);
	sunxi_lcd_delay_ms(200);
	sunxi_lcd_dsi_dcs_write_0para(sel, DSI_DCS_SET_DISPLAY_ON);
	sunxi_lcd_delay_ms(200);
}

static void LCD_panel_exit(u32 sel)
{
	sunxi_lcd_dsi_dcs_write_0para(sel, DSI_DCS_SET_DISPLAY_OFF);
	sunxi_lcd_delay_ms(20);
	sunxi_lcd_dsi_dcs_write_0para(sel, DSI_DCS_ENTER_SLEEP_MODE);
	sunxi_lcd_delay_ms(120);
}

/* sel: 0:lcd0; 1:lcd1 */
static s32 LCD_user_defined_func(u32 sel, u32 para1, u32 para2, u32 para3)
{
	return 0;
}

__lcd_panel_t eagle_1_720_1280_panel = {
	/* panel driver name, must mach the lcd_drv_name in sys_config.fex */
	.name = "eagle_1_720_1280",
	.func = {
		 .cfg_panel_info = LCD_cfg_panel_info,
		 .cfg_open_flow = LCD_open_flow,
		 .cfg_close_flow = LCD_close_flow,
		 .lcd_user_defined_func = LCD_user_defined_func,
		 }
	,
};
